package yf.platform.bo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Record;

import java.util.Map;

public class MetaObject extends Record{

    private static final long serialVersionUID = 1039791052455989472L;

    private static final Log logger = Log.getLog(MetaObject.class);

//	public static final MetaObject dao = new MetaObject();

    private static final String CREATEAT = "createAt";
    public static final String ID = "id";
    public static final String UPDATEAT = "updateAt";
    private static final String STATUS = "status";

    public int getId() {
        Integer o = this.get(ID);
        return o;
    }

    public MetaObject setId(int id) {
        this.set(ID,id);
        return this;
    }

    public long getCreateAt() {
        long o = this.get(CREATEAT);
        return o;
    }

    public MetaObject setCreateAt(long createat) {
        this.set(CREATEAT,createat);
        return this;
    }

    public long getUpdateAt() {
        long o = this.get(UPDATEAT);
        return o;
    }

    public MetaObject setUpdateAt(long updateAt) {
        this.set(UPDATEAT,updateAt);
        return this;
    }

    public int getStatus() {
        Integer o = this.get(STATUS);
        return o;
    }

    public MetaObject setStatus(int status) {
        this.set(STATUS,status);
        return this;
    }

    public MetaObject(){}
    public MetaObject(Map<String, Object> args) {
        this.setColumns(args);
    }

    public MetaObject(JSONObject args){
        String jsonStr = args.toJSONString();
        this.setColumns((Map<String,Object>)JSON.parse(jsonStr));
    }

    public MetaObject create(Map<String,Object> args){
        this.setColumns(args);
        this.setStatus(1);
        long now = System.currentTimeMillis();
        this.setCreateAt(now);
        this.setUpdateAt(now);
        return this;
    }
    public MetaObject create(){
        this.setStatus(1);
        long now = System.currentTimeMillis();
        this.setCreateAt(now);
        this.setUpdateAt(now);
        return this;
    }

    @Override
    public String toString() {
        return getColumns().toString();
    }


}
